<template>
  <div class="my">
    <div class="my-bg clearfix">
      <van-icon class="fl" name="setting-o" color="#fff" size="25" />
      <div class="logout fr" @click="logout">退出登录</div>
    </div>
    <div class="my-box">
      <div class="my-info">
        <div class="my-img">
          <img class="auto-img" src="../assets/home-active.png" alt="" />
        </div>
        <div class="user-info">
          <div class="user-name one-text">{{ nickName }}</div>
          <div class="desc one-text">这家伙很懒，什么都没留下！</div>
        </div>
        <div class="view-more">
          <van-tag class="go-infos" mark type="primary">个人主页</van-tag>
        </div>
      </div>
      <div class="myOrder">
        <div class="order-item">
          <div class="icon">
            <img src="../assets/weixiaof.png" alt="" class="auto-img" />
          </div>
          <div class="not-consumed">未消费</div>
        </div>
        <div class="order-item">
          <div class="icon">
            <van-icon
              class="daifukuan"
              name="gold-coin-o"
              size="34"
              color="#A9A9A9"
            />
            <!-- <img src="../assets/daifukuan.png" alt="" class="auto-img" /> -->
          </div>
          <div class="not-consumed">代付款</div>
        </div>
        <div class="order-item">
          <div class="icon">
            <img src="../assets/daipjia.png" alt="" class="auto-img" />
          </div>
          <div class="not-consumed">待评价</div>
        </div>
        <div class="order-item">
          <div class="icon">
            <img src="../assets/tuikuan.png" alt="" class="auto-img" />
          </div>
          <div class="not-consumed">未消费</div>
        </div>
      </div>
    </div>

    <div class="group">
      <van-cell-group>
        <van-cell title="我的消息" is-link />
        <van-cell title="我的收藏" is-link />
        <van-cell
          class="new-achieve"
          title="我的成就"
          value="达成新成就"
          is-link
        />
      </van-cell-group>
    </div>

    <div class="group">
      <van-cell-group>
        <van-cell title="我的钱包" value="支付管理" is-link />
        <van-cell title="余额" value="0元" is-link />
        <van-cell title="优惠券" is-link />
        <van-cell title="影院会员卡" is-link />
      </van-cell-group>
    </div>
  </div>
</template>

<script>
export default {
  name: "My",
  data() {
    return {
      isLogin: false,
      cookie: "",
      nickName: "",
      defaultAvatar: "",
    };
  },
  created() {
    this.getInfos();
  },
  methods: {
    // 获取登录信息
    getInfos() {
      // 获取cookie数据
      let cookieDate = document.cookie;
      // 

      // 将cookie字符串转换为方便操作的对象
      //按照; 切割
      let cookies = cookieDate.split("; ");
      //  //得到一个数组

      // 设置一个空对象来保存获取到的数据
      let cookieObject = {};

      for (let i = 0; i < cookies.length; i++) {
        // cookies[i]取出文本
        let c = cookies[i].split("="); // = 分割，取出=后的值
        //  //一个数组

        cookieObject[c[0]] = c[1];
      }
      // 

      // 获取账户名称
      this.nickName = cookieObject.account;
      // 
    },

    // 退出登录
    logout() {
      // 

      this.$router.push({ name: "Login" });

      localStorage.removeItem("_token");
    },
  },
};
</script>

<style lang="less" scoped>
.my {
  height: 620px;
  background-color: #f5f5f5;
}
.my-bg {
  height: 110px;
  // background-color: #dd403b;
  background-image: linear-gradient(to bottom, #dd403b 0px, #fb5268 90px);
  padding: 10px;
  .logout {
    font-size: 15px;
    color: #fff;
  }
}
.my-box {
  background-color: #fff;
  padding: 10px;
  margin: 0 10px;
  position: relative;
  top: -35px;
  border-radius: 10px;
}
.my-info {
  display: flex;
  align-items: center;
  .my-img {
    background-color: #ddd;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    overflow: hidden;
  }
  .user-info {
    font-size: 14px;
    margin-left: 10px;
    .user-name {
      font-size: 16px;
      font-weight: bold;
      color: #333;
    }
    .desc {
      color: #666;
      margin-top: 6px;
    }
  }
  .view-more {
    // border: 1px solid #000;
    // margin-left: 24px;
    position: relative;
    right: -12px;
    .go-infos {
      width: 66px;
      font-size: 13px;
    }

    .van-tag--mark {
      border-radius: 15px 0px 0px 15px;
      background-color: #fb5268;
      padding: 7px;
    }
    /deep/ .van-tag {
      justify-content: center;
    }
  }
}
.myOrder {
  // height: 100px;
  margin-top: 14px;
  border-top: 1px solid #ccc;
  padding-top: 10px;
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  // justify-content: space-around;
  .order-item {
    // border: 1px solid #000;
    border-right: 1px solid#ccc;
    padding: 0px 22px;
    &:last-child {
      padding-right: 0;
      border: none;
    }
    &:first-child {
      padding-left: 12px;
    }
  }
  .icon {
    // border: 1px solid #000;
    width: 26px;
    height: 26px;
    // margin-left: 8px;
    padding: 0 10px;
    .daifukuan {
      margin-top: -4px;
      margin-left: -2px;
    }
  }
  .not-consumed {
    // border: 1px solid #000;
    text-align: center;
    margin-top: 6px;
    font-size: 15px;
    color: #4c4c4c;
  }
}
.group {
  // border: 1px solid #000;
  margin-top: -10px;
  // margin-bottom: 12px;
  .van-cell {
    border-bottom: 1px solid #ccc;
    font-size: 15px;
    color: #4c4c4c;
  }
  .new-achieve {
    .van-cell__value {
      color: #dd403b;
      font-size: 14px;
    }
  }
  &:last-child {
    margin-top: 22px;
  }
}
</style>